# filename: find_latest_llm_paper.py
import requests
from xml.etree import ElementTree

def search_arxiv(query):
    base_url = "http://export.arxiv.org/api/query"
    params = {
        'search_query': query,
        'max_results': 10,
        'sortBy': 'submittedDate',
        'sortOrder': 'descending'
    }
    response = requests.get(base_url, params=params)
    return response.text

def parse_arxiv_response(xml_content):
    root = ElementTree.fromstring(xml_content)
    entries = root.findall('{http://www.w3.org/2005/Atom}entry')
    latest_paper = entries[0]
    title = latest_paper.find('{http://www.w3.org/2005/Atom}title').text
    summary = latest_paper.find('{http://www.w3.org/2005/Atom}summary').text
    published = latest_paper.find('{http://www.w3.org/2005/Atom}published').text
    link = latest_paper.find('{http://www.w3.org/2005/Atom}link').attrib['href']
    return title, summary, published, link

query = 'LLM agent'
xml_content = search_arxiv(query)
title, summary, published, link = parse_arxiv_response(xml_content)

print(f"Title: {title}")
print(f"Summary: {summary}")
print(f"Published: {published}")
print(f"Link: {link}")